Skip to contentSkip to conversation

Change in openvpn[master]: win: create adapter on demand

Openvpn-devel In review stipa (Code Review) 2 participants 12 messages Apr 18, 2025 – May 10, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1744973073000.I621d44ec6b0facc524875c15ddfd11ec47b06c15@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/943?usp=email

to review the following change.

Change subject: win: create adapter on demand
......................................................................

win: create adapter on demand

The installer currently creates one adapter per driver. When a user tries to start a second VPN connection while another is active, the client fails with an unclear error message:

"All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand when no available adapters exist. The client sends a command specifying the adapter type to the interactive service, which then executes tapctl.exe to create a new adapter.

This feature requires the interactive service, but this should not pose a problem since even our automatic service has recently started relying on the interactive service.

GitHub: #728

Change-Id I621d44ec6b0facc524875c15ddfd11ec47b06c15

---
M include/openvpn-msg.h
M src/openvpn/socket.c
M src/openvpn/tun.c
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.h

6 files changed, 154 insertions(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/43/943/1

include/openvpn-msg.h +13 -1
index 8b48053..2cf8d40 100644
@@ -47,7 +47,8 @@
     msg_register_ring_buffers,
     msg_set_mtu,
     msg_add_wins_cfg,
-    msg_del_wins_cfg
+    msg_del_wins_cfg,
+    msg_create_adapter
 } message_type_t;
 
 typedef struct {
@@ -172,4 +173,15 @@
     int mtu;
 } set_mtu_message_t;
 
+typedef enum {
+    ADAPTER_TYPE_DCO,
+    ADAPTER_TYPE_TAP,
+    ADAPTER_TYPE_WINTUN
+} adapter_type_t;
+
+typedef struct {
+    message_header_t header;
+    adapter_type_t adapter_type;
+} create_adapter_message_t;
+
 #endif /* ifndef OPENVPN_MSG_H_ */
src/openvpn/socket.c +1 -0
index a0c22b1..34a049e 100644
@@ -2231,6 +2231,7 @@
         ALLOC_OBJ_CLEAR(tt, struct tuntap);
 
         tt->backend_driver = DRIVER_DCO;
+        tt->options.msg_channel = c->options.msg_channel;
 
         const char *device_guid = NULL; /* not used */
         tun_open_device(tt, c->options.dev_node, &device_guid, &c->gc);
src/openvpn/tun.c +83 -9

135 lines not on this page · raw message

src/openvpnserv/common.c +8 -0
index 4a11e6c..198835e 100644
@@ -96,6 +96,14 @@
         goto out;
     }
 
+    swprintf(default_value, _countof(default_value), L"%ls\\bin", install_path);
+    error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir),
+                         default_value);
+    if (error != ERROR_SUCCESS)
+    {
+        goto out;
+    }
+
     error = GetRegString(key, L"config_ext", s->ext_string, sizeof(s->ext_string),
                          L".ovpn");
     if (error != ERROR_SUCCESS)
src/openvpnserv/interactive.c +48 -0

66 lines not on this page · raw message

src/openvpnserv/service.h +1 -0
index cbe213b..cebc67f 100644
@@ -63,6 +63,7 @@
 typedef struct {
     WCHAR exe_path[MAX_PATH];
     WCHAR config_dir[MAX_PATH];
+    WCHAR bin_dir[MAX_PATH];
     WCHAR ext_string[16];
     WCHAR log_dir[MAX_PATH];
     WCHAR ovpn_admin_group[MAX_NAME];

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/943?usp=email

to look at the new patch set (#2).

Change subject: win: create adapter on demand
......................................................................

win: create adapter on demand

The installer currently creates one adapter per driver. When a user tries to start a second VPN connection while another is active, the client fails with an unclear error message:

"All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand when no available adapters exist. The client sends a command specifying the adapter type to the interactive service, which then executes tapctl.exe to create a new adapter.

This feature requires the interactive service, but this should not pose a problem since even our automatic service has recently started relying on the interactive service.

GitHub: #728

Change-Id I621d44ec6b0facc524875c15ddfd11ec47b06c15

---
M include/openvpn-msg.h
M src/openvpn/socket.c
M src/openvpn/tun.c
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.h

6 files changed, 169 insertions(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/43/943/2

include/openvpn-msg.h +13 -1
index 8b48053..2cf8d40 100644
@@ -47,7 +47,8 @@
     msg_register_ring_buffers,
     msg_set_mtu,
     msg_add_wins_cfg,
-    msg_del_wins_cfg
+    msg_del_wins_cfg,
+    msg_create_adapter
 } message_type_t;
 
 typedef struct {
@@ -172,4 +173,15 @@
     int mtu;
 } set_mtu_message_t;
 
+typedef enum {
+    ADAPTER_TYPE_DCO,
+    ADAPTER_TYPE_TAP,
+    ADAPTER_TYPE_WINTUN
+} adapter_type_t;
+
+typedef struct {
+    message_header_t header;
+    adapter_type_t adapter_type;
+} create_adapter_message_t;
+
 #endif /* ifndef OPENVPN_MSG_H_ */
src/openvpn/socket.c +1 -0
index a0c22b1..34a049e 100644
@@ -2231,6 +2231,7 @@
         ALLOC_OBJ_CLEAR(tt, struct tuntap);
 
         tt->backend_driver = DRIVER_DCO;
+        tt->options.msg_channel = c->options.msg_channel;
 
         const char *device_guid = NULL; /* not used */
         tun_open_device(tt, c->options.dev_node, &device_guid, &c->gc);
src/openvpn/tun.c +92 -9

144 lines not on this page · raw message

src/openvpnserv/common.c +8 -0
index 4a11e6c..198835e 100644
@@ -96,6 +96,14 @@
         goto out;
     }
 
+    swprintf(default_value, _countof(default_value), L"%ls\\bin", install_path);
+    error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir),
+                         default_value);
+    if (error != ERROR_SUCCESS)
+    {
+        goto out;
+    }
+
     error = GetRegString(key, L"config_ext", s->ext_string, sizeof(s->ext_string),
                          L".ovpn");
     if (error != ERROR_SUCCESS)
src/openvpnserv/interactive.c +54 -0

72 lines not on this page · raw message

src/openvpnserv/service.h +1 -0
index cbe213b..cebc67f 100644
@@ -63,6 +63,7 @@
 typedef struct {
     WCHAR exe_path[MAX_PATH];
     WCHAR config_dir[MAX_PATH];
+    WCHAR bin_dir[MAX_PATH];
     WCHAR ext_string[16];
     WCHAR log_dir[MAX_PATH];
     WCHAR ovpn_admin_group[MAX_NAME];

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

selvanair has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

Change subject: win: create adapter on demand
......................................................................

Patch Set 2: Code-Review+2

(4 comments)

File src/openvpn/tun.c:

http://gerrit.openvpn.net/c/openvpn/+/943/comment/cb1bafd2_52f5f731 :
PS2, Line 3781: static struct device_instance_id_interface *
This change is not required nor advisable. Same with panel_reg and tap_reg below. Instead define them as const where used -- see below.

http://gerrit.openvpn.net/c/openvpn/+/943/comment/d1ebab33_cae54f35 :
PS2, Line 6656: struct device_instance_id_interface *device_instance_id_interface = get_device_instance_id_interface(gc);
Define these three as "const struct ...". One can still re-assign them as required below.

http://gerrit.openvpn.net/c/openvpn/+/943/comment/ebac2853_5ed7005b :
PS2, Line 6707: if (adapter_created || (h && !do_create_adapter_service(h, tt->backend_driver)))
I think we need not limit this using the adapter_created flag. There is a kind of "race condition" where the created adapter may get opened by another openvpn.exe process before this one gets a chance to open it. Especially so with service created instances which all startup together.

In such cases it should be okay to create a new one again in the next round of this while loop. That will work transparently if adapter_created is not set and checked. If some protection against a run-away loop is needed, we could keep it as a number instead of as a bool -- like, do not create > 10 adapters in a run!

http://gerrit.openvpn.net/c/openvpn/+/943/comment/7ae3b2cb_836cd3b3 :
PS2, Line 6731: if (tun_try_open_device(tt, *device_guid, device_instance_id_interface))
I think we should not limit this using the adapter_created flag here. There is a kind of "race condition" where the created adapter may get opened by another openvpn.exe process before this one gets a chance to open it. Especially so with service created instances which all startup together.

In such cases it should be okay to create again inn the second round which will work transparently if adapter_created is not set and checked. If some protectin against a run-away loop is needed, we could keep it as a number instead of as a bool -- like, do not create > 10 adapters!

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 23 Apr 2025 22:25:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

selvanair has removed a vote from this change. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

Change subject: win: create adapter on demand
......................................................................

Removed Code-Review+2 by selvanair <[email protected]...>
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: deleteVote

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, selvanair.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

Change subject: win: create adapter on demand
......................................................................

Patch Set 2:

(3 comments)

File src/openvpn/tun.c:

http://gerrit.openvpn.net/c/openvpn/+/943/comment/e2801d99_1753f1ba :
PS2, Line 3781: static struct device_instance_id_interface *

Quoted 1 line

This change is not required nor advisable. Same with panel_reg and tap_reg below. […]

Acknowledged

http://gerrit.openvpn.net/c/openvpn/+/943/comment/78901121_07cb7bb3 :
PS2, Line 6656: struct device_instance_id_interface *device_instance_id_interface = get_device_instance_id_interface(gc);

Quoted 1 line

Define these three as "const struct ...". One can still re-assign them as required below.

right, the data is const, but not the pointer.

http://gerrit.openvpn.net/c/openvpn/+/943/comment/36c92149_f13d12e9 :
PS2, Line 6731: if (tun_try_open_device(tt, *device_guid, device_instance_id_interface))

Quoted 1 line

I think we should not limit this using the adapter_created flag here. […]

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Thu, 24 Apr 2025 06:58:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: selvanair <[email protected]...>
Gerrit-MessageType: comment

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, selvanair.

Hello flichtenheld, plaisthos, selvanair,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/943?usp=email

to look at the new patch set (#3).

Change subject: win: create adapter on demand
......................................................................

win: create adapter on demand

The installer currently creates one adapter per driver. When a user tries to start a second VPN connection while another is active, the client fails with an unclear error message:

"All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand when no available adapters exist. The client sends a command specifying the adapter type to the interactive service, which then executes tapctl.exe to create a new adapter.

This feature requires the interactive service, but this should not pose a problem since even our automatic service has recently started relying on the interactive service.

GitHub: #728

Change-Id I621d44ec6b0facc524875c15ddfd11ec47b06c15

---
M include/openvpn-msg.h
M src/openvpn/socket.c
M src/openvpn/tun.c
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.h

6 files changed, 160 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/43/943/3

include/openvpn-msg.h +13 -1
index 8b48053..2cf8d40 100644
@@ -47,7 +47,8 @@
     msg_register_ring_buffers,
     msg_set_mtu,
     msg_add_wins_cfg,
-    msg_del_wins_cfg
+    msg_del_wins_cfg,
+    msg_create_adapter
 } message_type_t;
 
 typedef struct {
@@ -172,4 +173,15 @@
     int mtu;
 } set_mtu_message_t;
 
+typedef enum {
+    ADAPTER_TYPE_DCO,
+    ADAPTER_TYPE_TAP,
+    ADAPTER_TYPE_WINTUN
+} adapter_type_t;
+
+typedef struct {
+    message_header_t header;
+    adapter_type_t adapter_type;
+} create_adapter_message_t;
+
 #endif /* ifndef OPENVPN_MSG_H_ */
src/openvpn/socket.c +1 -0
index a0c22b1..34a049e 100644
@@ -2231,6 +2231,7 @@
         ALLOC_OBJ_CLEAR(tt, struct tuntap);
 
         tt->backend_driver = DRIVER_DCO;
+        tt->options.msg_channel = c->options.msg_channel;
 
         const char *device_guid = NULL; /* not used */
         tun_open_device(tt, c->options.dev_node, &device_guid, &c->gc);
src/openvpn/tun.c +83 -3

111 lines not on this page · raw message

src/openvpnserv/common.c +8 -0
index 4a11e6c..198835e 100644
@@ -96,6 +96,14 @@
         goto out;
     }
 
+    swprintf(default_value, _countof(default_value), L"%ls\\bin", install_path);
+    error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir),
+                         default_value);
+    if (error != ERROR_SUCCESS)
+    {
+        goto out;
+    }
+
     error = GetRegString(key, L"config_ext", s->ext_string, sizeof(s->ext_string),
                          L".ovpn");
     if (error != ERROR_SUCCESS)
src/openvpnserv/interactive.c +54 -0

72 lines not on this page · raw message

src/openvpnserv/service.h +1 -0
index cbe213b..cebc67f 100644
@@ -63,6 +63,7 @@
 typedef struct {
     WCHAR exe_path[MAX_PATH];
     WCHAR config_dir[MAX_PATH];
+    WCHAR bin_dir[MAX_PATH];
     WCHAR ext_string[16];
     WCHAR log_dir[MAX_PATH];
     WCHAR ovpn_admin_group[MAX_NAME];

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-MessageType: newpatchset

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, selvanair.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

Change subject: win: create adapter on demand
......................................................................

Patch Set 2:

(2 comments)

File src/openvpn/tun.c:

http://gerrit.openvpn.net/c/openvpn/+/943/comment/4f2d37c4_06eedd41 :
PS2, Line 6656: struct device_instance_id_interface *device_instance_id_interface = get_device_instance_id_interface(gc);

Quoted 1 line

right, the data is const, but not the pointer.

Acknowledged

http://gerrit.openvpn.net/c/openvpn/+/943/comment/9ce6ddd6_a5306ffa :
PS2, Line 6707: if (adapter_created || (h && !do_create_adapter_service(h, tt->backend_driver)))

Quoted 1 line

I think we need not limit this using the adapter_created flag. […]

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Thu, 24 Apr 2025 06:58:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: selvanair <[email protected]...>
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

selvanair has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

Change subject: win: create adapter on demand
......................................................................

Patch Set 3: Code-Review+2

(2 comments)

Patchset:

PS3:
Lightly tested on Win 10.

File src/openvpn/tun.c:

http://gerrit.openvpn.net/c/openvpn/+/943/comment/958666f9_30bda351 :
PS2, Line 6731: if (tun_try_open_device(tt, *device_guid, device_instance_id_interface))

Quoted 1 line

I think we should not limit this using the adapter_created flag here. […]

This comment got duplicated.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Thu, 24 Apr 2025 15:09:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: selvanair <[email protected]...>
Gerrit-MessageType: comment

#9 lore raw

PATCH v3 1/1 win: create adapter on demand

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

The installer currently creates one adapter per driver. When a user tries to start a second VPN connection while another is active, the client fails with an unclear error message:

"All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand when no available adapters exist. The client sends a command specifying the adapter type to the interactive service, which then executes tapctl.exe to create a new adapter.

This feature requires the interactive service, but this should not pose a problem since even our automatic service has recently started relying on the interactive service.

GitHub: #728

Change-Id I621d44ec6b0facc524875c15ddfd11ec47b06c15

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/943
This mail reflects revision 3 of this Change.

Acked-by according to Gerrit (reflected above):
Selva Nair <[email protected]...>

include/openvpn-msg.h +13 -1
index 8b48053..2cf8d40 100644
@@ -47,7 +47,8 @@
     msg_register_ring_buffers,
     msg_set_mtu,
     msg_add_wins_cfg,
-    msg_del_wins_cfg
+    msg_del_wins_cfg,
+    msg_create_adapter
 } message_type_t;
 
 typedef struct {
@@ -172,4 +173,15 @@
     int mtu;
 } set_mtu_message_t;
 
+typedef enum {
+    ADAPTER_TYPE_DCO,
+    ADAPTER_TYPE_TAP,
+    ADAPTER_TYPE_WINTUN
+} adapter_type_t;
+
+typedef struct {
+    message_header_t header;
+    adapter_type_t adapter_type;
+} create_adapter_message_t;
+
 #endif /* ifndef OPENVPN_MSG_H_ */
src/openvpn/socket.c +1 -0
index a0c22b1..34a049e 100644
@@ -2231,6 +2231,7 @@
         ALLOC_OBJ_CLEAR(tt, struct tuntap);
 
         tt->backend_driver = DRIVER_DCO;
+        tt->options.msg_channel = c->options.msg_channel;
 
         const char *device_guid = NULL; /* not used */
         tun_open_device(tt, c->options.dev_node, &device_guid, &c->gc);
src/openvpn/tun.c +83 -3

111 lines not on this page · raw message

src/openvpnserv/common.c +8 -0
index 4a11e6c..198835e 100644
@@ -96,6 +96,14 @@
         goto out;
     }
 
+    swprintf(default_value, _countof(default_value), L"%ls\\bin", install_path);
+    error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir),
+                         default_value);
+    if (error != ERROR_SUCCESS)
+    {
+        goto out;
+    }
+
     error = GetRegString(key, L"config_ext", s->ext_string, sizeof(s->ext_string),
                          L".ovpn");
     if (error != ERROR_SUCCESS)
src/openvpnserv/interactive.c +54 -0

72 lines not on this page · raw message

src/openvpnserv/service.h +1 -0
index cbe213b..cebc67f 100644
@@ -63,6 +63,7 @@
 typedef struct {
     WCHAR exe_path[MAX_PATH];
     WCHAR config_dir[MAX_PATH];
+    WCHAR bin_dir[MAX_PATH];
     WCHAR ext_string[16];
     WCHAR log_dir[MAX_PATH];
     WCHAR ovpn_admin_group[MAX_NAME];
#10 lore raw

[Openvpn-devel] [PATCH applied] Re: win: create adapter on demand

We have discussed this at the Community IRC meeting, and decided that "we do want this feature" (there was a bit of confusion as I thought we did not implement this previously for some good reason, but since nobody remembered anything we decided the reason wasn't so good, after all :-) ).

I have lightly stared at the code, tested to build on mingw64, and did not run the resulting binary. Selva did and +2'ed, so that's covered.

Your patch has been applied to the master branch.

commit c1c330b6d53bd78e2fd1731e886863c6fe099192

Author: Lev Stipakov
Date:   Sat May 10 20:19:30 2025 +0200
     win: create adapter on demand

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Selva Nair <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg31617.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#11 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#4) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by selvanair

Change subject: win: create adapter on demand
......................................................................

win: create adapter on demand

The installer currently creates one adapter per driver. When a user tries to start a second VPN connection while another is active, the client fails with an unclear error message:

"All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand when no available adapters exist. The client sends a command specifying the adapter type to the interactive service, which then executes tapctl.exe to create a new adapter.

This feature requires the interactive service, but this should not pose a problem since even our automatic service has recently started relying on the interactive service.

GitHub: OpenVPN/openvpn#728

Change-Id I621d44ec6b0facc524875c15ddfd11ec47b06c15

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31617.html

---
M include/openvpn-msg.h
M src/openvpn/socket.c
M src/openvpn/tun.c
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.h

6 files changed, 160 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/43/943/4

include/openvpn-msg.h +13 -1
index 8b48053..2cf8d40 100644
@@ -47,7 +47,8 @@
     msg_register_ring_buffers,
     msg_set_mtu,
     msg_add_wins_cfg,
-    msg_del_wins_cfg
+    msg_del_wins_cfg,
+    msg_create_adapter
 } message_type_t;
 
 typedef struct {
@@ -172,4 +173,15 @@
     int mtu;
 } set_mtu_message_t;
 
+typedef enum {
+    ADAPTER_TYPE_DCO,
+    ADAPTER_TYPE_TAP,
+    ADAPTER_TYPE_WINTUN
+} adapter_type_t;
+
+typedef struct {
+    message_header_t header;
+    adapter_type_t adapter_type;
+} create_adapter_message_t;
+
 #endif /* ifndef OPENVPN_MSG_H_ */
src/openvpn/socket.c +1 -0
index a0c22b1..34a049e 100644
@@ -2231,6 +2231,7 @@
         ALLOC_OBJ_CLEAR(tt, struct tuntap);
 
         tt->backend_driver = DRIVER_DCO;
+        tt->options.msg_channel = c->options.msg_channel;
 
         const char *device_guid = NULL; /* not used */
         tun_open_device(tt, c->options.dev_node, &device_guid, &c->gc);
src/openvpn/tun.c +83 -3

111 lines not on this page · raw message

src/openvpnserv/common.c +8 -0
index 4a11e6c..198835e 100644
@@ -96,6 +96,14 @@
         goto out;
     }
 
+    swprintf(default_value, _countof(default_value), L"%ls\\bin", install_path);
+    error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir),
+                         default_value);
+    if (error != ERROR_SUCCESS)
+    {
+        goto out;
+    }
+
     error = GetRegString(key, L"config_ext", s->ext_string, sizeof(s->ext_string),
                          L".ovpn");
     if (error != ERROR_SUCCESS)
src/openvpnserv/interactive.c +54 -0

72 lines not on this page · raw message

src/openvpnserv/service.h +1 -0
index cbe213b..cebc67f 100644
@@ -63,6 +63,7 @@
 typedef struct {
     WCHAR exe_path[MAX_PATH];
     WCHAR config_dir[MAX_PATH];
+    WCHAR bin_dir[MAX_PATH];
     WCHAR ext_string[16];
     WCHAR log_dir[MAX_PATH];
     WCHAR ovpn_admin_group[MAX_NAME];

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 4
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#12 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/943?usp=email )

Change subject: win: create adapter on demand
......................................................................

win: create adapter on demand

The installer currently creates one adapter per driver. When a user tries to start a second VPN connection while another is active, the client fails with an unclear error message:

"All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand when no available adapters exist. The client sends a command specifying the adapter type to the interactive service, which then executes tapctl.exe to create a new adapter.

This feature requires the interactive service, but this should not pose a problem since even our automatic service has recently started relying on the interactive service.

GitHub: OpenVPN/openvpn#728

Change-Id I621d44ec6b0facc524875c15ddfd11ec47b06c15

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31617.html

---
M include/openvpn-msg.h
M src/openvpn/socket.c
M src/openvpn/tun.c
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c
M src/openvpnserv/service.h

6 files changed, 160 insertions(+), 4 deletions(-)
include/openvpn-msg.h +13 -1
index 8b48053..2cf8d40 100644
@@ -47,7 +47,8 @@
     msg_register_ring_buffers,
     msg_set_mtu,
     msg_add_wins_cfg,
-    msg_del_wins_cfg
+    msg_del_wins_cfg,
+    msg_create_adapter
 } message_type_t;
 
 typedef struct {
@@ -172,4 +173,15 @@
     int mtu;
 } set_mtu_message_t;
 
+typedef enum {
+    ADAPTER_TYPE_DCO,
+    ADAPTER_TYPE_TAP,
+    ADAPTER_TYPE_WINTUN
+} adapter_type_t;
+
+typedef struct {
+    message_header_t header;
+    adapter_type_t adapter_type;
+} create_adapter_message_t;
+
 #endif /* ifndef OPENVPN_MSG_H_ */
src/openvpn/socket.c +1 -0
index a0c22b1..34a049e 100644
@@ -2231,6 +2231,7 @@
         ALLOC_OBJ_CLEAR(tt, struct tuntap);
 
         tt->backend_driver = DRIVER_DCO;
+        tt->options.msg_channel = c->options.msg_channel;
 
         const char *device_guid = NULL; /* not used */
         tun_open_device(tt, c->options.dev_node, &device_guid, &c->gc);
src/openvpn/tun.c +83 -3

111 lines not on this page · raw message

src/openvpnserv/common.c +8 -0
index 4a11e6c..198835e 100644
@@ -96,6 +96,14 @@
         goto out;
     }
 
+    swprintf(default_value, _countof(default_value), L"%ls\\bin", install_path);
+    error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir),
+                         default_value);
+    if (error != ERROR_SUCCESS)
+    {
+        goto out;
+    }
+
     error = GetRegString(key, L"config_ext", s->ext_string, sizeof(s->ext_string),
                          L".ovpn");
     if (error != ERROR_SUCCESS)
src/openvpnserv/interactive.c +54 -0

72 lines not on this page · raw message

src/openvpnserv/service.h +1 -0
index cbe213b..cebc67f 100644
@@ -63,6 +63,7 @@
 typedef struct {
     WCHAR exe_path[MAX_PATH];
     WCHAR config_dir[MAX_PATH];
+    WCHAR bin_dir[MAX_PATH];
     WCHAR ext_string[16];
     WCHAR log_dir[MAX_PATH];
     WCHAR ovpn_admin_group[MAX_NAME];

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/943?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Gerrit-Change-Number: 943
Gerrit-PatchSet: 4
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged